<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\ApiPresetCollection;
use App\Model\Repository\ApiRequestPresetRepository;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;

class ApiPresetController extends Controller
{
    public function index(Request $request)
    {
        $project_id = $request->get('project_id');
        return new ApiPresetCollection(ApiRequestPresetRepository::when($project_id, function (Builder $builder) use ($project_id) {
            $builder->where([
                ['project_id', '=', $project_id],
                ['part', '=', 'body']
            ]);
        })->get());
    }


    /**
     * Display the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

}
